﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharePoint.Contrib.Extensions
{
    /// <summary>
    /// Extension methods for the Object class
    /// </summary>
    public static class ObjectExtensions
    {
        /// <summary>
        /// Gets a collection of attributes(of a certain type) found on a type
        /// </summary>
        public static IEnumerable<T> Attributes<T>(this object instance) where T : Attribute
        {
            var attributes = Attribute.GetCustomAttributes(instance.GetType(), typeof(T), false) as T[];
            return attributes;
        }
    }
}
